<html lang="en">
    <head>
        <meta name="viewport" content="width=device-width,initial-scale=1.0">
        <title>实验2</title>
    </head>
    <body>
        <!--229971318 李明星-->
        <div>
            第1题
        </div>
        <div>
            (1)
        </div>
        <script>
            console.log(Number(true),Number(null),+undefined);
            //Number(true)会被转化为1，null会被转化成0，
        </script>
        
    <div>
        (2)
    </div>    
    <script>
        console.log(Boolean('100'),Boolean('100'),Boolean(null),!!undefined);
        //结果为ture true false false，因为Boolean()是将给定的值转换为布尔型，第一个是字符串、第二个是整形，第三个为空值，第四为双重非操作符
    </script>

     <div>
        (3)
    </div>    
    <script>
        console.log(parseInt(123.6),parseInt(0b1011011),parseInt(0X2A),parseInt(0X2A,8) );
        //结果为123 91 42 34
    </script>

<div>
    (4)
</div>    
<script>
    console.log(parseFloat('123.6'),parseFloat('100px'),parseFloat('010') );
    //该函数的返回值为浮点型和NaN,会将参数变为浮点型，
</script>

<div>
    (5)
</div>    
<script>
    console.log(eval('87*99+2'));
    //eval()eval 函数用于执行一个字符串表达式，并返回表达式的结果。使用 eval('87*99+2') 时，eval 函数会解析并执行字符串 '87*99+2' 中的数学表达式
</script>

<div>
    (6)
</div>    
<script>
    console.log(isNaN(null),isNaN('123'),isNaN('abc'),isNaN('a1b2c3'));
    //结果为false false true true
</script>
</script>

<div>
    第2题
</div>
<div>
    (1)
</div>
<script>
    var arr1 = [];
    console.log(arr1,arr1.length);
    var arr2 = [1,2,3];
    console.log(arr2[0],arr2.length);
    var arr3 = new Array();
    console.log(arr3[1],arr3.length);
    arr2.splice(0,1);//删除arr2数组中的第一个元素（0，1）0号，1个
    console.log(arr2[0],arr2.length);
</script>

<div>
    (2)
</div>
<script>
    var arr1 = [];
    console.log(arr1,arr1.length);
    var arr2 = [1,2,3];
    console.log(arr2[0],arr2.length);
    var arr3 = new Array();
    console.log(arr3[1],arr3.length);
</script>

<div>
    第3题
</div>
<script>
    //获取时间
    var d = new Date();
    h=d.getHours();
    f=d.getMinutes();
    console.log(h,f);
</script>

<div>
    第4题
</div>
<div>
   (1)
</div>
<script>
    var reg1 = /^\d{4}$/;
    console.log(reg1.test('1234'),
            reg1.test('1a34'),
            reg1.test('12345')
        )
    </script>
    
    
<div>
    (2)
 </div>
 <script>
    var reg2=new RegExp("^[sp]\\d{1,4}$","i");
    console.log(reg2.test('p123'),
        reg2.test('1234'),
        reg2.test('S10')
    )
</script>

<div>
    (3)
 </div>
 <script>
        var reg3=new RegExp(/^1(33|53|89|80)\d{8}$/);
        console.log(reg3.test('13312345678'),
            reg3.test('12312345678'),
            reg3.test('133123456789')
        )
 </script>
 
 <div>
    第5题
</div>
<div>
   (1)
</div>
<script>
     var obj=new String('3198073575@qq.com');
        w=obj.split('@');
        console.log(w[0]);
</script>

<div>
    第6题
</div>
<script>
   var x=Math.round(2.6);
        console.log(x);
</script>

<div>
    第7题
</div>
<script>
 var x=1;
        function A(y){
            var x=2;
            function B(z){
                console.log(x+y+z);
            }
            return B;
        }
        var C=A(2);
        C(3);//2+2+3=7
</script>
